<template>
  <div id="app">
    <header>
        <span class="headr_title">{{this.$store.state.headerTitle}}</span>
        <span v-show="this.$store.state.showBack" @click="historyBack" class="icons-fanhui"></span>
    </header>
    <router-view></router-view>
    <div class="js_dialog" id="error-dialog" v-show="$store.state.errorMsg != ''" >
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <!-- <div class="weui-dialog__hd"><strong class="weui-dialog__title">弹窗标题</strong></div> -->
            <div class="weui-dialog__bd">{{$store.state.errorMsg}}</div>
            <div class="weui-dialog__ft">
            <a @click="clearErroMsg" href="javascript:;" class="weui-dialog__btn primary">确定</a>
            </div>
        </div>
    </div>
    <loading></loading>
  </div>
</template>

<script>
import loading from './components/loading.vue';
export default {
    name: 'app',
    components: {
        'loading': loading,
    },
    methods:{
        clearErroMsg(){
            this.$store.state.errorMsg = "";
        },
        historyBack(){
            if(location.hash=="#/accountRecord" || location.hash == "#/loanRecord"){
                location.hash = "#/mer/" + this.$store.state.tlMerId +"?openid="+this.$store.state.openid;
            }else{
                window.history.back();
            }

        }
    },
    beforeUpdate:function(){
        console.log("beforeUpdate...........")
        if(this.$store.state.errorMsg == "Security exception"){
            this.$store.state.errorMsg = "无效微信号";
        }
    },
    beforeRouteLeave :function  (to,from,next) {
        console.dir("beforeEnterbeforeEnter....");


    },

};
</script>

<style  lang='scss'>
@import './assets/scss/index.scss';
@import './assets/scss/_header.scss';
@import './assets/scss/xtCommon.scss';
body{
   background:#f5f5f9;
}
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

}





.btn_box{
    margin-top: 15px;
    padding:15px;
}
</style>
